/**
 * Created by linc on 2017/5/9.
 */
var express = require('express');

var sub = express.Router();

sub.post('/sign-in', function (req, res) {
  var body = req.body;
  var password = body.password;
  switch (password) {
    case '401':
      // 密码不正确 401
      res.json({
        code: 401
      });
      //res.status(401).json(null);
      break;
    case '404':
      // 用户名不存在 404
      res.json({
        code: 404
      });
      break;
    case 'res404':
      res.status(404).json(null);
      break;
    case 'res500':
      res.status(500).json(null);
      break;
    default :
      res.json({
        code: 200,
        data: {
          token: 'token'
        }
      });
  }
});
sub.delete('/sign-out', function (req, res) {
  res.json({
    code: 200,
    data: {}
  })
});
sub.get('/user', function (req, res) {
  res.json({
    code: 200,
    data: {
      id: 'id',
      email: 'email@fp.com',
      nickName: 'nickName',
      avatar: 'https://www.primefaces.org/barcelona-ng/assets/layout/images/profile-image.png'
    }
  })
});

module.exports = sub;
